package com.kt.common.collections

fun main() {
    //区间与数列 rangeTo()
    //var a:Int =2
    //if (a in 1..4) println(a)
    //正向迭代
    //for (t in 1..4) print(t)
    //降序迭代
    //for (i in 4 downTo 1) print(i)
    //增加步长
    //for (i in 1..8 step 2) print(i)
    /*for (i in 1 until 10) {       // i in [1, 10), 10被排除
        print(i)
    }*/

    /**区间*/
    //val versionRange = Version(1, 11)..Version(1, 30)

    println((1..10).filter { it % 2 == 0 })
}

class Version(val major: Int, val minor: Int): Comparable<Version> {
    override fun compareTo(other: Version): Int {
        if (this.major != other.major) {
            return this.major - other.major
        }
        return this.minor - other.minor
    }
}